package com.cloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: my
 * @BelongsPackage: com.cloud.controller
 * @Author: ji ge
 * @CreateTime: 2024-02-02  19:09
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
//@RequestMapping("/payment")
public class PaymentController {
//    @Resource
//    private PaymentService paymentService;

    @Value("@{server.port}")
    private String serverPort;

////    @Resource
////    private DiscoveryClient discoveryClient;
//
//    @GetMapping("/get/{id}")
//    public R<Pay> get(@PathVariable("id") Long id) {
//        Pay pay = paymentService.get(id);
//        return new R<Pay>(200, "select success server port:" + serverPort, pay);
//    }
//
//    @PostMapping("/create")
//    public R<Pay> create(@RequestBody Pay pay) {
//        Pay insert = paymentService.insert(pay);
//        return new R<Pay>(200, "select success server port:" + serverPort, insert);
//
//    }
//
//    @GetMapping("/queryAllByLimit")
//    public R<List<Pay>> queryAllByLimit(@RequestParam(defaultValue = "0") int offset,
//                                        @RequestParam(defaultValue = "10") int limit) {
//        List<Pay> payList = paymentService.queryAllByLimit(offset, limit);
//        return new R(200, "select success ,server port :" + serverPort, payList);
//    }
//
////    @GetMapping("/discovery")
////    public Object discovery() {
////        List<ServiceInstance> instances = discoveryClient.getInstances("CLOUD-PAYMENT-SERVICE");
////        instances.forEach(i -> {
////            System.out.println(i.getServiceId() + "\t" + i.getHost() + "\t" + i.getPort() + "\t" + i.getUri());
////        });
////        return this.discoveryClient;
////    }
//
//    @GetMapping("/lb")
//    public String lb() {
//        return serverPort;
//    }
//
//    @GetMapping("/feignTimeOut")
//    public String feignTimeOut() {
//        try {
//            TimeUnit.SECONDS.sleep(3);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        return serverPort;
//    }

    @GetMapping("/paymentZipkin")
    public String paymentZipkin() {
        return "payment zipkin  ";
    }
}
